const { ObjectId } = require('bson')
const mongoose = require('mongoose')
const { Schema } = mongoose

// 博客详情表规则
const blog = new Schema({
  title: {
    type: String,
    required: true
  },
  tags: {
    type: Array
  },
  description: {
    type: String
  },
  cover: {
    type: String
  },
  content: {
    type: String,
    required: true
  },
  comment: { // 复杂结构
    type: Array
  },
  author_id: {
    type: ObjectId,
    required: true
  },
  lastModified: {
    type: Date
  },
  views: {
    type: Number
  },
  likes: {
    type: Number
  },
  blogId: {
    type: Number,
    required: true
  },
  approved: {
    type: Boolean
  }
})

const blogTable = mongoose.model('blogTable', blog)

module.exports = blogTable
